﻿using Coldairarrow.Business.Base_leasesystem_serviceaccount;
using Coldairarrow.Entity.Base_leasesystem_serviceaccount;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_serviceaccount
{
    /// <summary>
    /// 服务商银行账号控制器
    /// </summary>
    [Route("/Base_leasesystem_serviceaccount/[controller]/[action]")]
    [OpenApiTag("服务商银行账号控制器")]
    public class leasesystem_serviceaccountController : BaseApiController
    {
        #region DI

        public leasesystem_serviceaccountController(Ileasesystem_serviceaccountBusiness leasesystem_serviceaccountBus)
        {
            _leasesystem_serviceaccountBus = leasesystem_serviceaccountBus;
        }

        Ileasesystem_serviceaccountBusiness _leasesystem_serviceaccountBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_serviceaccount>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_serviceaccountBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_serviceaccount> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_serviceaccountBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_serviceaccount data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_serviceaccountBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_serviceaccountBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("serviceaccount.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_serviceaccountBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}